package com.ruoyi.customerSample.service.impl;

import com.ruoyi.common.utils.DateUtils;

import com.ruoyi.customerSample.domain.SampleSendDetails;
import com.ruoyi.customerSample.mapper.SampleSendDetailsMapper;
import com.ruoyi.customerSample.service.ISampleSendDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 来样登记明细信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
@Service
public class SampleSendDetailsServiceImpl implements ISampleSendDetailsService
{
    @Autowired(required = false)
    private SampleSendDetailsMapper sampleSendDetailsMapper;

    /**
     * 查询来样登记明细信息
     * 
     * @param id 来样登记明细信息ID
     * @return 来样登记明细信息
     */
    @Override
    public SampleSendDetails selectSampleSendDetailsById(String id)
    {
        return sampleSendDetailsMapper.selectSampleSendDetailsById(id);
    }

    /**
     * 根据来样单位和日期获取明细信息
     * @param client
     * @param reDate
     * @return
     */
    @Override
    public List<SampleSendDetails> selectSampleSendDetailsByClient(String client, String reDate) {
        return sampleSendDetailsMapper.selectSampleSendDetailsByClient(client, reDate);
    }

    /**
     * 获取最大编号
     * @param sampleNum
     * @return
     */
    @Override
    public String selectNumMax(String sampleNum) {
        //拼接数据
        sampleNum =  "YB" + sampleNum + DateUtils.getYear();
        Integer num = sampleSendDetailsMapper.selectNumMax(sampleNum);
        if(null == num) {
            num = 0001;
            return String.format("%04d", num);
        }else {
            return String.format("%04d", num + 1);
        }
    }

    /**
     * 查询来样登记明细信息列表
     * 
     * @param sampleSendDetails 来样登记明细信息
     * @return 来样登记明细信息
     */
    @Override
    public List<SampleSendDetails> selectSampleSendDetailsList(SampleSendDetails sampleSendDetails)
    {
        return sampleSendDetailsMapper.selectSampleSendDetailsList(sampleSendDetails);
    }

    /**
     * 新增来样登记明细信息
     * 
     * @param sampleSendDetails 来样登记明细信息
     * @return 结果
     */
    @Override
    public int insertSampleSendDetails(SampleSendDetails sampleSendDetails)
    {
        return sampleSendDetailsMapper.insertSampleSendDetails(sampleSendDetails);
    }

    /**
     * 批量新增明细信息
     * @param sampleSendDetails
     * @return
     */
    @Override
    public int batchSampleSendDetails(List<SampleSendDetails> sampleSendDetails) {
        return sampleSendDetailsMapper.batchSampleSendDetails(sampleSendDetails);
    }

    /**
     * 修改来样登记明细信息
     * 
     * @param sampleSendDetails 来样登记明细信息
     * @return 结果
     */
    @Override
    public int updateSampleSendDetails(SampleSendDetails sampleSendDetails)
    {
        return sampleSendDetailsMapper.updateSampleSendDetails(sampleSendDetails);
    }

    /**
     * 批量删除来样登记明细信息
     * 
     * @param ids 需要删除的来样登记明细信息ID
     * @return 结果
     */
    @Override
    public int deleteSampleSendDetailsByIds(String[] ids)
    {
        return sampleSendDetailsMapper.deleteSampleSendDetailsByIds(ids);
    }

    /**
     * 删除来样登记明细信息信息
     * 
     * @param id 来样登记明细信息ID
     * @return 结果
     */
    @Override
    public int deleteSampleSendDetailsById(String id)
    {
        return sampleSendDetailsMapper.deleteSampleSendDetailsById(id);
    }
}
